package com.mycompany.rest;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.mycompany.optimizaproject.Incidente;
import com.mycompany.optimizaproject.TipoIncidenteExtra;
import com.mycompany.services.dao.TipoIncidenteExtraDAO;

@Controller
@RequestMapping("/tipo-incidente-extra")
public class TipoIncidenteExtraRestController extends AbstractRestController<TipoIncidenteExtra, Integer> {

	@Autowired
	private TipoIncidenteExtraDAO tipoIncidenteExtraDAO;

	public void init() {
		setDao(tipoIncidenteExtraDAO);
	}

	@RequestMapping(value = "", method = RequestMethod.GET)
	public ModelAndView getIncidentesByUser(@RequestParam("tipoIncidente") int tipoIncidente) {
		try {
			List<TipoIncidenteExtra> incidentes = this.tipoIncidenteExtraDAO.tipoIncidenteExtraSegunTipoIncidente(tipoIncidente);
			log.debug("Returing incidentes: " + incidentes.toString());
			return new ModelAndView(jsonView_i, "data", incidentes);
		} catch (Exception e) {
			e.printStackTrace();
			log.error("Error al intentar obtener la lista", e);
			return createErrorResponse("Error Inesperado. Comuniquese con el administrador");
		}

	}
	
}
